home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / metamail / contrib / emacs / mime-rt.el < prev    next >
Encoding:
Text File  |  1993-02-08  |  3.7 KB  |  106 lines

  1. ;; 
  2. ;; Some stuff to aid in the composition of MIME richtext.  This is designed
  3. ;; to be used with mime-compose.el by Marc Andreessen (marca@ncsa.uiuc.edu).
  4. ;;
  5. ;; We create a keymap and fill it with one-letter abbreviations to insert 
  6. ;; the MIME Richtext keywords.  We bind this new keymap to C-cC-r in the 
  7. ;; mh-letter-mode, or C-r in the mail-mode (I don't use RMAIL so I don't 
  8. ;; know if this clashes with anything....)
  9. ;;
  10. ;; This allows the single sequence C-cC-rb to insert the tokens 
  11. ;; "<bold></bold>" in the current buffer at the current point, then leave
  12. ;; the point between the "><" characters.
  13. ;;
  14. ;; Not all the MIME keywords are supported; only the ones likely to be used 
  15. ;; by me.
  16. ;;
  17. ;; I use it by putting the following in my .emacs, so that mh will load it 
  18. ;; when required:
  19. ;;    (defun my-mh-letter-mode-hooks () (require 'mime-rt))
  20. ;;    (setq mh-letter-mode-hook 'my-mh-letter-mode-hooks)
  21. ;;
  22. ;; Gregory Bond, gnb@bby.com.au, 8 Feb 1993.
  23. ;; This file is in the public domain.
  24. ;;
  25. ;; The following keymap entries are made:
  26. ;;
  27. ;; C-c C-r p    mime-rt-new-page
  28. ;; C-c C-r RET    mime-rt-new-line
  29. ;; C-c C-r n    mime-rt-new-line
  30. ;; C-c C-r C-l    mime-rt-lt
  31. ;; C-c C-r <    mime-rt-lt
  32. ;; C-c C-r _    mime-rt-subscript
  33. ;; C-c C-r ^    mime-rt-superscript
  34. ;; C-c C-r c    mime-rt-center
  35. ;; C-c C-r u    mime-rt-underline
  36. ;; C-c C-r g    mime-rt-bigger
  37. ;; C-c C-r m    mime-rt-smaller
  38. ;; C-c C-r f    mime-rt-fixed
  39. ;; C-c C-r i    mime-rt-italic
  40. ;; C-c C-r b    mime-rt-bold
  41.  
  42. (require 'mime-compose)
  43. (provide 'mime-rt)
  44.  
  45. (defvar mime-rt-map (make-sparse-keymap)
  46.   "A keymap used to insert MIME richtext tokens.")
  47.  
  48. (if mime-running-mh-e
  49.     (define-key mh-letter-mode-map "\C-c\C-r" mime-rt-map)
  50.   ; I don't use RMAIL, so I hope this is OK!
  51.     (define-key mail-mode-map "\C-r" mime-rt-map))
  52.   
  53. (defun mime-rt-insert-keyword-pair (keyword)
  54.   "Insert a Mime Richtext keyword pair \"<KEYWORD></KEYWORD>\"."
  55.   (interactive "sMIME Richtext Keyword: ")
  56.   (insert (format "<%s></%s>" keyword keyword))
  57.   (forward-word -1)
  58.   (forward-char -2))
  59.  
  60. ;
  61. ; Define a function and map a key to do a mime keyword
  62. ;
  63. (defmacro mime-rt-make-keymap-entry (keyword letter)
  64.   "Make a function called \"mime-rt-<KEYWORD>\" to insert the Mime richtext
  65. keyword pairs at the current point.  Adds an entry to the mime-rt-map with 
  66. LETTER to access that function."
  67.   (let ((fn-name (intern (concat "mime-rt-" keyword))) ; A SYMBOL
  68.     )
  69.     (` (progn
  70.      (defun (, fn-name) ()
  71.        (interactive)
  72.        (mime-rt-insert-keyword-pair (, keyword)))
  73.      (define-key mime-rt-map (, letter) '(, fn-name))))))
  74.  
  75. ;
  76. ; Now the actual keys
  77. ;
  78. (mime-rt-make-keymap-entry "bold" "b")
  79. (mime-rt-make-keymap-entry "italic" "i")
  80. (mime-rt-make-keymap-entry "fixed" "f")
  81. (mime-rt-make-keymap-entry "smaller" "m") ; sMaller
  82. (mime-rt-make-keymap-entry "bigger" "g") ; biGger
  83. (mime-rt-make-keymap-entry "underline" "u")
  84. (mime-rt-make-keymap-entry "center" "c")
  85. (mime-rt-make-keymap-entry "superscript" "^") ;a la TeX math mode
  86. (mime-rt-make-keymap-entry "subscript" "_") ;a la TeX math mode
  87.  
  88. ;
  89. ; These ones don't have the balancing </...> form
  90. ; They are just inserts so I can do it in the define-key
  91. ; _BUT_ then C-hC-m gives ?? as the binding for that key.  So do 
  92. ; a defun anyway.
  93. (defun mime-rt-lt () (interactive) (insert "<lt>"))
  94. (defun mime-rt-new-line () (interactive) (insert "<nl>"))
  95. (defun mime-rt-new-page () (interactive) (insert "<np>"))
  96.  
  97. (define-key mime-rt-map "<" 'mime-rt-lt)
  98. (define-key mime-rt-map "\C-l" 'mime-rt-lt) ; C-< is C-, is C-L, Easier to type!
  99. (define-key mime-rt-map "n" 'mime-rt-new-line)
  100. (define-key mime-rt-map "\C-m" 'mime-rt-new-line) ;Enter as well.
  101. (define-key mime-rt-map "p" 'mime-rt-new-page)
  102.  
  103. --
  104. Gregory Bond <gnb@bby.com.au> Burdett Buckeridge & Young Ltd Melbourne Australia
  105.             Dizzy Gillespie: RIP.
  106.